package com.hongxun.modules.eys.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongxun.modules.eys.entity.EWorkContentEntity;
import com.hongxun.modules.eys.service.EWorkContentService;
import com.hongxun.common.utils.PageUtils;
import com.hongxun.common.utils.Query;
import com.hongxun.common.utils.R;




/**
 * 点位工作内容明细表
 * 
 * @author zkcn
 * @email youeremail@163.com
 * @date 2018-09-21 14:22:33
 */
@RestController
@RequestMapping("/eys/eworkcontent")
public class EWorkContentController {
	@Autowired
	private EWorkContentService eWorkContentService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("eys:eworkcontent:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);
        String wheres =" 1=1 ";
        query.put("filterSql",wheres+" ");
		List<EWorkContentEntity> eWorkContentList = eWorkContentService.queryList(query);
		int total = eWorkContentService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(eWorkContentList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{guid}")
	@RequiresPermissions("eys:eworkcontent:info")
	public R info(@PathVariable("guid") String guid){
		EWorkContentEntity eWorkContent = eWorkContentService.queryObject(guid);
		
		return R.ok().put("eWorkContent", eWorkContent);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("eys:eworkcontent:save")
	public R save(@RequestBody EWorkContentEntity eWorkContent){
		eWorkContentService.save(eWorkContent);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("eys:eworkcontent:update")
	public R update(@RequestBody EWorkContentEntity eWorkContent){
		eWorkContentService.update(eWorkContent);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("eys:eworkcontent:delete")
	public R delete(@RequestBody String[] guids){
		eWorkContentService.deleteBatch(guids);
		
		return R.ok();
	}
	
}
